// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境

const db = cloud.database()
const feedback = db.collection('c_feedback')
const _ = db.command

// 云函数入口函数
exports.main = async (event, context) => {

  try {
    await feedback.add({
      data: {
        feedbackInfo: event.feedback
      }
    })
    return {
      code: 20000,
      msg: "添加反馈成功"
    }
  } catch (err) {
    return {
      code: 1001,
      data: null,
      msg: "添加反馈失败"
    }
  }

}